-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduces is* functions for strings #3432
Open
ancailliau
wants to merge
7
commits into
vertexproject:master
Choose a base branch
from
ancailliau:stormtype-str-is-methods
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Introduces is* functions for strings #3432
ancailliau
wants to merge
7
commits into
vertexproject:master
from
ancailliau:stormtype-str-is-methods
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vEpiphyte
reviewed
Dec 5, 2023
vEpiphyte
reviewed
Dec 5, 2023
ancailliau
force-pushed
the
stormtype-str-is-methods
branch
from
April 12, 2024 14:21
a789b58
to
4fbe895
Compare
I missed the notification. I updated according to the review. |
vEpiphyte
reviewed
Apr 12, 2024
vEpiphyte
requested changes
May 1, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ancailliau Can you please apply the following patch to get tests passing?
diff --git a/synapse/lib/stormtypes.py b/synapse/lib/stormtypes.py
index 354dac361..37da9ab18 100644
--- a/synapse/lib/stormtypes.py
+++ b/synapse/lib/stormtypes.py
@@ -4409,8 +4409,8 @@ class Str(Prim):
$foo="aca123" return ( $foo.isAlnum() ) // true
''',
- 'type': {'type': 'function', '_funcname': '_methStrIsAlnum',
- 'returns': {'type': 'bool', 'desc': 'Whether string is alphanumeric', }}},
+ 'type': {'type': 'function', '_funcname': '_methStrIsAlNum',
+ 'returns': {'type': 'boolean', 'desc': 'Whether string is alphanumeric', }}},
{'name': 'isAlpha', 'desc': '''
Returns true if all chars in the string are in the alphabet, false otherwise.
@@ -4420,7 +4420,7 @@ class Str(Prim):
$foo="aca" return ( $foo.isAlpha() ) // true
''',
'type': {'type': 'function', '_funcname': '_methStrIsAlpha',
- 'returns': {'type': 'bool', 'desc': 'Whether string only contains chars from alphabet', }}},
+ 'returns': {'type': 'boolean', 'desc': 'Whether string only contains chars from alphabet', }}},
{'name': 'isAscii', 'desc': '''
Returns true if all chars in the string are ASCII chars, false otherwise.
@@ -4430,7 +4430,7 @@ class Str(Prim):
$foo="aca" return ( $foo.isAscii() ) // true
''',
'type': {'type': 'function', '_funcname': '_methStrIsASCII',
- 'returns': {'type': 'bool', 'desc': 'Whether all the chars are ASCII', }}},
+ 'returns': {'type': 'boolean', 'desc': 'Whether all the chars are ASCII', }}},
{'name': 'isDecimal', 'desc': '''
Returns true if all the chars are decimals (including unicode), false otherwise.
@@ -4440,7 +4440,7 @@ class Str(Prim):
$foo="123" return ( $foo.isDecimal() ) // true
''',
'type': {'type': 'function', '_funcname': '_methStrIsDecimal',
- 'returns': {'type': 'bool', 'desc': 'Whether all the chars are decimals', }}},
+ 'returns': {'type': 'boolean', 'desc': 'Whether all the chars are decimals', }}},
{'name': 'isDigit', 'desc': '''
Returns true if all the chars are decimals, false otherwise.
Exponents are considered as digits.
@@ -4451,7 +4451,7 @@ class Str(Prim):
$foo="123" return ( $foo.isDigit() ) // true
''',
'type': {'type': 'function', '_funcname': '_methStrIsDigit',
- 'returns': {'type': 'bool', 'desc': 'Whether all the chars are digits', }}},
+ 'returns': {'type': 'boolean', 'desc': 'Whether all the chars are digits', }}},
{'name': 'isIdentifier', 'desc': '''
Returns true if the string is a valid identifier, false otherwise.
A valid identifier only contains alphanumeric letters (a-z) and (0-9), or underscores (_).
@@ -4463,7 +4463,7 @@ class Str(Prim):
$foo="aca_123" return ( $foo.isIdentifier() ) // true
''',
'type': {'type': 'function', '_funcname': '_methStrIsIdentifier',
- 'returns': {'type': 'bool', 'desc': 'Whether the string is a valid identifier', }}},
+ 'returns': {'type': 'boolean', 'desc': 'Whether the string is a valid identifier', }}},
{'name': 'isLower', 'desc': '''
Returns true if all the chars are in lower case, false otherwise.
Numbers, symbols and spaces are not checked, only alphabet characters.
@@ -4474,7 +4474,7 @@ class Str(Prim):
$foo="aca" return ( $foo.isLower() ) // true
''',
'type': {'type': 'function', '_funcname': '_methStrIsLower',
- 'returns': {'type': 'bool', 'desc': 'Whether all chars are in lower case', }}},
+ 'returns': {'type': 'boolean', 'desc': 'Whether all chars are in lower case', }}},
{'name': 'isNumeric', 'desc': '''
Returns true if all the chars are numeric, false otherwise.
Unicode fractions are considered as numeric, but not decimals like `1.5`.
@@ -4485,7 +4485,7 @@ class Str(Prim):
$foo="123" return ( $foo.isNumeric() ) // true
''',
'type': {'type': 'function', '_funcname': '_methStrIsNumeric',
- 'returns': {'type': 'bool', 'desc': 'Whether all chars are numeric', }}},
+ 'returns': {'type': 'boolean', 'desc': 'Whether all chars are numeric', }}},
{'name': 'isPrintable', 'desc': '''
Returns true if all the chars are printable, false otherwise.
@@ -4495,7 +4495,7 @@ class Str(Prim):
$foo="aca 123" return ( $foo.isPrintable() ) // true
''',
'type': {'type': 'function', '_funcname': '_methStrIsPrintable',
- 'returns': {'type': 'bool', 'desc': 'Whether all chars are printable', }}},
+ 'returns': {'type': 'boolean', 'desc': 'Whether all chars are printable', }}},
{'name': 'isSpace', 'desc': '''
Returns true if all the chars are whitespaces, false otherwise.
@@ -4505,7 +4505,7 @@ class Str(Prim):
$foo=" " return ( $foo.isSpace() ) // true
''',
'type': {'type': 'function', '_funcname': '_methStrIsSpace',
- 'returns': {'type': 'bool', 'desc': 'Whether all chars are whitespaces', }}},
+ 'returns': {'type': 'boolean', 'desc': 'Whether all chars are whitespaces', }}},
{'name': 'isTitle', 'desc': '''
Returns true if all words in a text start with a upper case letter and others are lower case, false otherwise.
@@ -4515,7 +4515,7 @@ class Str(Prim):
$foo="Aca Test" return ( $foo.isTitle() ) // true
''',
'type': {'type': 'function', '_funcname': '_methStrIsTitle',
- 'returns': {'type': 'bool', 'desc': 'Whether all words starts with an upper case', }}},
+ 'returns': {'type': 'boolean', 'desc': 'Whether all words starts with an upper case', }}},
{'name': 'isUpper', 'desc': '''
Returns true if all the characters are in upper case, false otherwise.
Numbers, symbols and spaces are not checked, only alphabet characters.
@@ -4526,7 +4526,7 @@ class Str(Prim):
$foo="ACA" return ( $foo.isUpper() ) // true
''',
'type': {'type': 'function', '_funcname': '_methStrIsUpper',
- 'returns': {'type': 'bool', 'desc': 'Whether all chars are upper case', }}},
+ 'returns': {'type': 'boolean', 'desc': 'Whether all chars are upper case', }}},
)
_storm_typename = 'str'
_ismutable = False
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduces additional functions for testing strings. These are generally faster and more readable than their regular expression equivalent. I found those useful when writing rapid power-ups and integrations with 3rd party services.
Methods are a direct mapping from their Python equivalent
isalnum()
isalpha()
isascii()
isdecimal()
isdigit()
isidentifier()
islower()
isnumeric()
isprintable()
isspace()
istitle()
isupper()